package com.ming.springcloud.student.service;

import com.ming.springcloud.student.dao.IDeviceDao;
import com.ming.springcloud.student.pojo.Device;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

@Service("deviceService")
public class DeviceServiceImpl implements IDeviceService{
    @Resource
    @Autowired
    private IDeviceDao deviceDao;
    @Override
    public Page<Device> findAllDevices(Pageable pageable) {
        return deviceDao.findAll(pageable);
    }

    @Override
    public void delete(Integer id) {
        deviceDao.deleteById(id);
    }

    @Override
    public void save(Device device) {
        deviceDao.save(device);
    }

    @Override
    public Optional<Device> findUserById(Integer id) {
        return deviceDao.findById(id);
    }

    @Override
    public void edit(Device device) {
        deviceDao.save(device);
    }

    @Override
    public List<Device> findBydeviceNameLike(String name) {
        return deviceDao.findBydeviceNameLike(name);
    }

    @Override
    public List<Device> findAll() {
        return deviceDao.findAll();
    }
}
